package com.wf.model.request;

import com.wf.model.enums.ResultCode;
import com.wf.model.exception.WorkflowException;
import org.springframework.util.StringUtils;

/**
 * @author shuaidongdong
 */
public class ApplyHistoryJsonRequest extends PageRequest implements FormatCheckRequest {

    private String userId;
    private String tenantId;
    private String approveType;
    private String applyUserName;
    /**
     * 审批事项
     */
    private String approveName;
    /**
     * 审批人用户编号
     */
    private String approveUserId;
    private String approveState;

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getTenantId() {
        return tenantId;
    }

    public void setTenantId(String tenantId) {
        this.tenantId = tenantId;
    }

    public String getApproveType() {
        return approveType;
    }

    public void setApproveType(String approveType) {
        this.approveType = approveType;
    }

    public String getApplyUserName() {
        return applyUserName;
    }

    public void setApplyUserName(String applyUserName) {
        this.applyUserName = applyUserName;
    }

    public String getApproveName() {
        return approveName;
    }

    public void setApproveName(String approveName) {
        this.approveName = approveName;
    }

    public String getApproveState() {
        return approveState;
    }

    public void setApproveState(String approveState) {
        this.approveState = approveState;
    }

    public String getApproveUserId() {
        return approveUserId;
    }

    public void setApproveUserId(String approveUserId) {
        this.approveUserId = approveUserId;
    }

    @Override
    public void formatCheck() {
        boolean success = true;
        if (StringUtils.isEmpty(userId)) {
            success = false;
        }
        if (StringUtils.isEmpty(approveState)) {
            approveState = null;
        }
        if (approveName != null) {
            approveName = approveName.trim();
        }
        if (applyUserName != null) {
            applyUserName = applyUserName.trim();
        }
        if (!success) {
            throw new WorkflowException(ResultCode.INVALID_ARGUMENT, "获取不到用户编号");
        }
    }

    @Override
    public String toString() {
        return "ApplyHistoryJsonRequest{" +
                "userId='" + userId + '\'' +
                ", tenantId='" + tenantId + '\'' +
                ", approveType='" + approveType + '\'' +
                ", applyUserName='" + applyUserName + '\'' +
                ", approveName='" + approveName + '\'' +
                ", approveState='" + approveState + '\'' +
                '}';
    }
}
